<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
	layout:decorator="app/layout/layout">

<body id="mainBody">
	<section layout:fragment="content">
		<div class="container" id="contentFragment">
			<br /> <br />

			<div th:fragment="abmModuloFragment">

				<form id="abmModuloForm" name="abmModuloForm"
					th:action="@{'/modulos/crear'}" class="form-horizontal"
					th:method="@{'POST'}">
					<div id="toReRender">
						<div th:fragment="datosModuloFragment" th:object="${modulo}"
							id="datosModuloFragment">
							<input type="hidden" id="hasErrors"
								th:value="${saveError} ? 'true' : 'false'" /> <input
								type="hidden" id="abmModuloAction"
								th:value="*{id != null} and *{id != 0} ? 'UPD' : 'INS'" /> <input
								type="hidden" id="id" th:field="*{id}" />
							<div class="panel panel-info">
								<div class="panel-heading">
									<h4>Datos del módulo</h4>
								</div>
								<br/><br/>
								<div class="form-group">
									<div class="col-sm-10">
										<label class="col-sm-4 control-label">Nombre<span
											class="required">*</span></label>
										<div class="col-sm-4">
											<input type="text" th:field="*{nombre}" name="nombre"
												placeholder="Ingrese el nombre del módulo"
												class="form-control uppercase" id="nombre" value=""
												autocomplete="off" required="required" autofocus="autofocus"
												tabindex="1" title="Nombre del módulo" />
										</div>
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-10">
										<label class="col-sm-4 control-label">Descripción<span
											class="required">*</span></label>
										<div class="col-sm-8">
											<input type="text" th:field="*{descripcion}" name="nombre"
												placeholder="Ingrese la descripción del módulo"
												class="form-control uppercase" id="descripcion" value=""
												autocomplete="off" required="required" autofocus="autofocus"
												tabindex="2" title="Descripción del módulo" />
										</div>
									</div>
								</div>


								<div class="form-group">
									<div class="col-sm-10">
										<label class="col-sm-4 control-label">Fecha Inicio<span
											class="required">*</span></label>
										<div class="col-sm-8">
											<input type="text" th:field="*{fechaInicio}"
												name="fechaInicio" placeholder="dd/mm/yyyy"
												class="form-control uppercase" id="fechaInicio" value=""
												autocomplete="off" autofocus="autofocus"
												tabindex="3" title="Fecha de inicio del módulo" />
										</div>
									</div>
								</div>

								<div class="form-group">
									<div class="col-sm-10">
										<label class="col-sm-4 control-label">Fecha Fin<span
											class="required">*</span></label>
										<div class="col-sm-8">
											<input type="text" th:field="*{fechaFin}" name="fechaFin"
												placeholder="dd/mm/yyyy" class="form-control uppercase"
												id="fechaFin" value="" autocomplete="off"
												tabindex="4"
												title="Fecha de fin del módulo" />
										</div>
									</div>
								</div>

								<div class="form-group">
									<div class="col-lg-12 text-center">
										<button type="button" class="btn btn-primary" onclick="guardar();"
											id="saveModuloBtn" data-loading-text="Guardando..."
											data-role="button"
											data-original-title="Presione el boton para guardar los datos..."
											title="" data-toggle="tooltip" data-placement="right"
											name="saveModuloBtn" th:text="@{'Guardar'}">Guardar</button>
									</div>
								</div>
							</div>
						</div>
					</div>

				</form>

			</div>

		</div>

	</section>
	<footer>
		<section layout:fragment="custom-footer">
			<script type="text/javascript">
			
				function guardar(){
					var frm = $('#abmModuloForm');
					if ($('#abmModuloAction').val() === 'UPD'){
						frm.attr('action', '/sisale/modulos/actualizar');
					}else{
						frm.attr('action', '/sisale/modulos/crear');
					}
					frm.submit();
				}
				
			</script>
		</section>
	</footer>
</body>
</html>